Namespace ShapeLibrary
    Friend Class Text
        Inherits Shape
        Private m_color As Color = Drawing.Color.Black
        Private m_font As New Font("Verdana", 8, FontStyle.Regular, GraphicsUnit.Pixel)
        Private m_startPoint As PointF
        Private m_text As String
        Private m_allign As StringAlignment = StringAlignment.Center


        Sub New(ByVal text As String, ByVal point As PointF)
            m_text = text
            m_startPoint = point
        End Sub
        Sub New(ByVal text As String, ByVal point As PointF, ByVal font As Font)
            m_text = text
            m_startPoint = point
            m_font = font
        End Sub
        Sub New(ByVal text As String, ByVal point As PointF, ByVal colour As Color)
            m_text = text
            m_startPoint = point
            m_color = colour
        End Sub
        Sub New(ByVal text As String, ByVal point As PointF, ByVal colour As Color, ByVal font As Font)
            m_text = text
            m_startPoint = point
            m_font = font
            m_color = colour
        End Sub
        Sub New(ByVal text As String, ByVal point As PointF, ByVal colour As Color, ByVal font As Font, ByVal Allign As StringAlignment)
            m_text = text
            m_startPoint = point
            m_font = font
            m_color = colour
            m_allign = Allign
        End Sub

        '''
        ''' The color that will be used to draw the line.
        '''
        <Description("The color of the line.")> _
        Public Property Color() As Color
            Get
                Return m_color
            End Get

            Set(ByVal Value As Color)
                m_color = Value
            End Set
        End Property
        '''
        ''' The start point, in pixels, of the line.
        '''
        <Description("The starting point of the line.")> _
        Public Property StartPoint() As PointF
            Get
                Return m_startPoint
            End Get

            Set(ByVal Value As PointF)
                m_startPoint = Value
            End Set
        End Property
        <Description("The Text to display")> _
            Public Property text() As String
            Get
                Return m_text
            End Get

            Set(ByVal Value As String)
                m_text = Value
            End Set
        End Property
        Public Property Allign() As StringAlignment
            Get
                Return m_allign
            End Get
            Set(ByVal value As StringAlignment)
                m_allign = value
            End Set
        End Property

        <Description("The Font to display")> _
                Public Property Font() As Font
            Get
                Return m_font
            End Get

            Set(ByVal Value As Font)
                m_font = Value
            End Set
        End Property
        '''
        ''' Overrides Shape.Draw to draw our line.
        '''
        Friend Overrides Sub Draw(ByVal g As Graphics)
            Dim p As New SolidBrush(m_color)
            Try
                g.TextContrast = 4
                Dim stringFormat As New StringFormat
                stringFormat.Alignment = m_allign
                stringFormat.LineAlignment = StringAlignment.Center
                g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAliasGridFit
                g.DrawString(m_text, m_font, p, m_startPoint, stringFormat)
                'p.Width = m_width
                ' g.DrawLine(p, StartPoint, EndPoint)
            Catch
                Debug.Print("ERROR DRAWING TEXT")
            Finally
                p.Dispose()
            End Try
        End Sub
    End Class
End Namespace